PDM2 - Interfaces for a Product Data
Manager
In this example three interfaces are used to expose the Catalog-Part-Attribute
class hierarchy, which represents a Product Data Manager (PDM) system.
This example demonstrates how to:
-
Expose persistent objects using the full exposure
approach
-
Implement the interfaces as CORBA server objects
-
Develop a command line client for the interface
Source Files
-
pdm.idl
Interface Definition Language (IDL) file for the interfaces CatalogIF,
PartIF, and AttributeIF in the pdm module. (IF stands for interface.)
Also defined are exception "PdmError" and the data structures AttributeData
and PartData.
The interface CatalogIF has get and edit operations, which manage the
Parts in the catalog. There are two types of operations: shallow
and deep. Shallow operations involve only primitive data types and
object references. Deep operations contains data structures (PartData
and AttributeData).
Deep operations are used to transfer an entire tree of data via one
call to the server, whereas shallow operations are more flexible for navigating
between different parts in a product tree. Object references returned
by shallow get operations enable fine-grained editing of Part's and Attribute's.
The interface PartIF is similar to CatalogIF. It manages its attributes
and component parts.
The current design for AttributeIF only handles attributes with a double
value, although there are other types of attributes in the persistent layer.
You are encouraged to enhance this interface.
-
Server.java
The Server code, which has a main function that creates an instance
of the CatalogImpl class and calls impl_is_ready() (via a separate
thread class BoaThread) to make it available to the client.
The code also defines a thread class TerminalThread, which is used to
run a console session for direct access to the database.
Another similar thread may also be started to process commands from an
input command file if it is present. To shutdown the server, type
in "shutdown" from the console.
-
Interface Layer Objects
The following interface implementation classes are present:
Implementation for
the interface "PartIF". It contains a persistent Part object as a servant
class.
-
AttributeImpl.java
Implementation for the interface "AttributeIF". It contains a persistent
Attribute object as a servant class. Note that this class also wraps
around other subclasses of Attribute so that we do need to create one Impl
class for each subclass of Attribute.
Other features, such as access control, may be added to these classes.
-
Persistent Layer Objects
The following interface implementation classes are present:
It contains a set
of persistent Part objects as components and a set of persistent Attribute
objects.
Note that they are all subclasses of NamedObject.java,
which simply has a name. The class DBManager.java
is used to facilitate database management. The class PVector.java
is a persistent enabled vector. All persistent enabled class are
listed in Cfpargs, which is used by the database
schema post processor.
-
LayerMediator.java
This class mediates the objects between the interface and persistent
layers. It also contains a hashtable of interface objects (with the
persistent objects as keys) so that we will not duplicate existing interface
objects.
-
Client.java
The command line client code. It binds to the CatalogImpl object
using the server name "PDM2 Server". It then waits for user commands.
The runTerminal method translates command line inputs into method calls
to the server.
Batch Files
-
build.bat
A batch file for building the client and server on Windows.
To build just the Java codes, simply type "build". To build also
the IDL code, use "build idl". (Note: if the subdirectory pdm is
not present, "build" will also build the IDL code.)
For the latter case, it will first invoke the IDL compiler and then
compile the client source codes for pdm.idl. A subdirectory named
"pdm" will be created, which contains the CORBA stub codes and their corresponding
class files. A jar file pdm.jar is generated afterwards (which is
not used for now).
-
runsrv.bat
A batch file for running the server. The command line format is:
runsrv
The server name is "PDM2 Server".
client.bat
A batch file for running the client. The command line format is:
client [hostname] [command.txt]
where the optional hostname (or IP address) is where the server is running
and command.txt is an optional input command file. (Note:
"localhost" may not work for certain network setup. Use the actual
hostname or IP address in that case.)
setenv.bat
A batch file for setting some environment variables.
run.bat
A batch file for running a test of the persistent objects.
clean.bat
A batch file for cleaning up the directories, leaving only source codes.
Running the Codes
This example was developed under VisiBroker (link).
To run the codes with the command line client, make sure that the VisiBroker
Smart Agent (osagent) is running on the server object's network. Then enter
the commands:
On Windows:
start runsrv
client (or client [hostname])
On Unix:
vbj Server &
vbj Client (or vbj Client [hostname])